#version 330

layout(location = 0) out vec4 FragColor;

uniform int windowWidth;
uniform int windowHeight;

uniform sampler2D textureSSAO;

void main()
{
	const float SSAODisstanceLimit = .2;
	vec2 textureCoord = vec2(gl_FragCoord.x / windowWidth, gl_FragCoord.y / windowHeight);

	FragColor = vec4(textureCoord, 0, 1);
	FragColor = texture(textureSSAO, textureCoord);
	
	float distance = 1;
	vec2 texelSize = distance / vec2(textureSize(textureSSAO, 0));
	float result = 0;
	for (int x = -2; x < 2; ++x)
	{
		for (int y = -2; y < 2; ++y)
		{
			vec2 offset = vec2(float(x), float(y))*texelSize;
			float shadowValue = texture(textureSSAO, textureCoord + offset).r;
			result += shadowValue;
		}
	}
	FragColor = vec4(result / 16);

	//FragColor = texture(textureSSAO, textureCoord);
}